package order;

import model.*;
import javax.swing.JOptionPane;


public class UpgradeTechnologyLevel extends UpgradeOrder{
  private final Player player;
  
  public UpgradeTechnologyLevel(Player player){
	  this.player = player;
  }
  
  public Territory getSource(){return null;}
  public Territory getDestination(){return null;}
  public boolean checkOrder(){
	  if (player.getTechnology() < player.getLevel().LevelCost()){
		  JOptionPane.showMessageDialog(null, "No enough technology to upgrade!");
		  return false;
	  }
	  else return true;
  }
  
  public void executeOrder(){
	  player.cutTechnology(player.getLevel().LevelCost());
	  player.upgradeLevel();
  }
  
  public void undoOrder(){
	  player.addTechnology(player.getLevel().Previous().LevelCost());
	  player.downgradeLevel();
  }
  
  public  String printOrder(){
  	StringBuffer sentence = new StringBuffer();
  	sentence.append("Upgrade technology level to ");
    sentence.append(player.getLevel().Next());  
   	sentence.append(" (Cost " + player.getLevel().LevelCost() + " Technology) ");
  	return sentence.toString();
  }
}


